/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "TimeIndicatorItem.h"
#include "DiagramView.h"

namespace QSThink
{
	TimeIndicatorItem::TimeIndicatorItem( DiagramView *view)
		: _view(view)
	{
		setFlag(ItemIsSelectable);//ItemIsMovable
		setFlag(ItemSendsGeometryChanges);
		setCacheMode(DeviceCoordinateCache);
		setAcceptHoverEvents(false);

		setZValue(1);
	}

	

	QRectF TimeIndicatorItem::boundingRect() const
	{
		int height=_view->maxHeight();

		
		return QRectF(0,0,2, height);

	}


	QPainterPath TimeIndicatorItem::shape() const
	{
		QPainterPath path;
		path.addRect(boundingRect());
		return path;
	}

	void TimeIndicatorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
	{
		painter->setPen(Qt::black);

		int height=_view->maxHeight();

		painter->drawLine(0,0,0,height);
		
	}

	QVariant TimeIndicatorItem::itemChange( GraphicsItemChange change, const QVariant &value )
	{
		

		return QGraphicsItem::itemChange(change, value);


	}

	void TimeIndicatorItem::mousePressEvent( QGraphicsSceneMouseEvent *evt )
	{
		update();
		QGraphicsItem::mousePressEvent(evt);

	}

	void TimeIndicatorItem::mouseReleaseEvent( QGraphicsSceneMouseEvent *evt )
	{
		update();
		QGraphicsItem::mouseReleaseEvent(evt);

	}

	

	TimeIndicatorItem::~TimeIndicatorItem()
	{
		
	}

}
